

`define ALUCtrlAND 4'd0
`define ALUCtrlOR 4'd1 
`define ALUCtrlSLT 4'd2
`define ALUCtrlnone 4'd3

`define ALUCtrlADD 4'd4
`define ALUCtrlSUB 4'd5

`define ALUCtrlXOR 4'd6 
`define ALUCtrlNOR 4'd7 
`define ALUCtrlSLLV  4'd8

module ALUCU (
        input [5:0] funct,
        input [1:0] ALUOp,
        output reg [3:0] ALUCtrl
    );

    always @(*) begin

        casex(ALUOp)
            2'b00:
                ALUCtrl <= `ALUCtrlADD;
            2'b01:
                ALUCtrl <= `ALUCtrlSUB;
            2'b1x: begin
                if (funct == 6'b100100) begin
                    ALUCtrl = `ALUCtrlAND;
                end
                else if (funct == 6'b100101) begin
                    ALUCtrl = `ALUCtrlOR;
                end
                else if (funct == 6'b100000) begin
                    ALUCtrl = `ALUCtrlADD;
                end
                else if (funct == 6'b100010) begin
                    ALUCtrl = `ALUCtrlSUB;
                end
                else if (funct == 6'b101010) begin
                    ALUCtrl = `ALUCtrlSLT;
                end
                else if (funct == 6'b100110) begin
                    ALUCtrl = `ALUCtrlXOR;
                end
                else if (funct == 6'b100111) begin
                    ALUCtrl = `ALUCtrlNOR;
                end
                else if (funct == 6'b000100) begin
                    ALUCtrl = `ALUCtrlSLLV;
                end
                else begin
                    ALUCtrl = `ALUCtrlnone;
                end
            end
        endcase
    end
endmodule

